<?php
/**
 * 附近门店导航小程序模块订阅器
 *
 * @author hellozjx
 * @url 
 */
defined('IN_IA') or exit('Access Denied');

class hellozjx_mapwxappModuleReceiver extends WeModuleReceiver {
	public function receive() {
		global $_W, $_GPC;
		$cfg=$this->module["config"];
		$type = $this->message['type'];
		$event=$this->message['event'];
		if($type=="event"&&$event=="user_enter_tempsession"&&$cfg['contact']==1)
		{
			$token = $this->getAccessToken();
			$wxapp_openid=$this->message['fromusername'];
		}
	}
	private function getAccessToken() {
		global $_W;
		load()->model('account');
		$acid = $_W['acid'];
		if (empty($acid)) {
			$acid = $_W['uniacid'];
		}
		$account = WeAccount::create($acid);
		//$token = $account->fetch_available_token();
        $token = $account->getAccessToken();
		return $token;
	}
}